# coding=utf-8

# from selenium.webdriver.common.keys import Keys
# from framework.base_page import BasePage
# from framework.logger import Logger
# from datetime
# # create a logger instance
# logger = Logger(logger="Components").getlog()
#
# class Components(BasePage):

    # def __init__(self):


    # def component_selection(self, el_selectbox, el_shiplist, el_shipinput=None, select_name, filter_info=None):
    #     '''
    #     :param el_selectbox:    选择框的定位
    #     :param el_shiplist:     选择列表的定位
    #     :param el_input:        输入框的定位
    #     :param select_name:     要选择选项的名称
    #     :param text:            要过滤的信息
    #     :return:
    #     '''
    #
    #     self.click(self.el_selectbox)
    #     if (filter_info is not None | self.el_shipinput is not None):
    #         self.type(self.el_shipinput, filter_info)
    #         self.sleep(5)
    #     else:
    #         raise NameError("Please enter a element of input_ship.")
    #     list_ship = self.find_elements(self.el_shiplist)
    #     for ship in list_ship:
    #         if select_name in ship.text:
    #             ship.click()
    #             break

    # 日期控件: 开始日期 - 结束日期
    # def component_StartToEnd(self, span_eta, input_eta_start, td_date_1, input_eta_end, date_start, date_end):
    #     try:
    #         datetime.datetime.strptime(date_start, '%Y-%m-%d')
    #         datetime.datetime.strptime(date_end, '%Y-%m-%d')
    #     except ValueError as e:
    #         logger.error("ValueException: %s" % e)
    #         # raise ValueError("Incorrect data format, should be YYYY_MM_DD")
    #     self.click(span_eta)
    #     self.type(input_eta_start, date_start)
    #     self.click(td_date_1)
    #     self.click(span_eta)
    #     self.simulateCtrlA(input_eta_end)
    #     self.type(input_eta_end, date_end)
    #     self.type(input_eta_end, Keys.ENTER)  # 模拟回车键操作

    # 获取报价信息
    # def get_quota_info(self, number):
    #
    #     card_mes = {}
    #
    #     card_list = 'xpath=>//div[@class="card-list"]/div'
    #     length = len(self.find_elements(card_list))
    #     try:
    #         if (number < length):
    #             # 船名，IMO和港口
    #             card_ship_name = card_list + '[' + str(
    #                 number) + ']/div[@class="quotation-card-item quotation-card-left"]/div[@class="qc-ship"]/div[@class="qc-ship-name"]'
    #             card_ship_imo = card_list + '[' + str(
    #                 number) + ']/div[@class="quotation-card-item quotation-card-left"]/div[@class="qc-ship"]/div[@class="qc-ship-imo"]'
    #             card_qc_port = card_list + '[' + str(
    #                 number) + ']/div[@class="quotation-card-item quotation-card-left"]/div[@class="qc-port qc-item"]/div'
    #
    #             # ETA，服务类型和委托方名
    #             card_qc_time = card_list + '[' + str(
    #                 number) + ']/div[@class="quotation-card-item quotation-card-center"]/div[@class="qc-time qc-item"]'
    #             card_qc_service_type = card_list + '[' + str(
    #                 number) + ']/div[@class="quotation-card-item quotation-card-center"]/div[@class="qc-servicetype qc-item"]'
    #             card_qc_principal = card_list + '[' + str(
    #                 number) + ']/div[@class="quotation-card-item quotation-card-center"]/div[@class="qc-principal qc-item"]'
    #
    #             # 红点，状态，价格和询价单号
    #             card_new_bool = card_list + '[' + str(
    #                 number) + ']/div[@class="quotation-card-item quotation-card-right"]/div[@class="qc-status-box"]/span/sup'
    #             # card_new_bool = 'xpath=>//div[@class="card-list"]/div[1]/div[@class="quotation-card-item quotation-card-right"]/div[@class="qc-status-box"]/span/sup'
    #             card_qc_status = card_list + '[' + str(
    #                 number) + ']/div[@class="quotation-card-item quotation-card-right"]/div[@class="qc-status-box"]/div[@class="qc-status"]'
    #             card_qc_price = card_list + '[' + str(
    #                 number) + ']/div[@class="quotation-card-item quotation-card-right"]/div[@class="qc-price"]/span/span'
    #             card_qc_no = card_list + '[' + str(
    #                 number) + ']/div[@class="quotation-card-item quotation-card-right"]/div[@class="qc-number qc-item"]/span'
    #
    #             # new 图标
    #             card_new_icon_bool = card_list + '[' + str(number) + ']/div[@class="new-icon"]/span'
    #
    #             card_mes['card_ship_name'] = self.find_element(card_ship_name).get_attribute("title")
    #             card_mes['card_ship_imo'] = \
    #             self.find_element(card_ship_imo).get_attribute("textContent").split(':')[1]
    #             card_mes['card_qc_port'] = self.find_element(card_qc_port).get_attribute("textContent")
    #             card_mes['card_qc_time'] = self.find_element(card_qc_time).get_attribute("textContent")
    #             card_mes['card_qc_service_type'] = self.find_element(card_qc_service_type).get_attribute(
    #                 "textContent")
    #             card_mes['card_qc_principal'] = self.find_element(card_qc_principal).get_attribute("textContent")
    #
    #             card_mes['card_new_bool'] = self.isElementExist(card_new_bool)
    #
    #             card_mes['card_qc_status'] = self.find_element(card_qc_status).get_attribute("textContent")
    #             card_mes['card_qc_price'] = self.find_element(card_qc_price).get_attribute("innerText")
    #             card_mes['card_qc_no'] = self.find_element(card_qc_no).get_attribute("innerText").split(':')[1]
    #             card_mes['card_new_icon_bool'] = self.isElementExist(card_new_icon_bool)
    #             return card_mes
    #         else:
    #             raise ValueError("你输入的行数大于数据卡行总数！！")
    #     except Exception as e:
    #         logger.error("Failed to get_card_info with: %s" % e)

    # 获取报价列表
    # def get_quota_list(self):
    #     card_list = []
    #
    #     card_list = 'xpath=>//div[@class="card-list"]/div'
    #     length = len(self.find_elements(card_list))
    #     for index in range(length):
    #         cardinfo = {}
    #         cardinfo = self.get_card_info(index)
    #         card_list.append(cardinfo)
    #     return card_list